package com.ks.user.controller;


import com.ks.core.core.Result;
import com.ks.core.dto.SearchCriteriaBase;
import com.ks.user.controller.dto.EmployeeRequest;
import com.ks.user.entity.OrgEmployee;
import com.ks.user.service.IOrgEmployeeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ks.core.base._ControllerBase;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 组织员工数据 前端控制器
 * </p>
 *
 * @author kingdee123
 * @since 2020-11-30
 */
@RestController
@RequestMapping("/orgEmployee")
public class OrgEmployeeController extends _ControllerBase {

    @Autowired
    private IOrgEmployeeService orgEmployeeService;


    @PostMapping("/getEmployeeList")
    @ApiOperation(value = "获取员工列表接口", notes = "获取员工列表接口")
    public Object getEmployeeList(@RequestBody SearchCriteriaBase searchCriteriaBase) {
        Map<String, Object> employeeList = orgEmployeeService.getEmployeeList(getContext(), searchCriteriaBase);
        return Result.success(employeeList);
    }


    @PostMapping("/getList")
    @ApiOperation(value = "获取员工列表接口不分页", notes = "获取员工列表接口不分页")
    public Object getList() {
        List<OrgEmployee> list = orgEmployeeService.getList(getContext());
        return Result.success(list);
    }

    @PostMapping("/delEmployee")
    @ApiOperation(value = "删除员工信息", notes = "删除员工信息")
    public Object delEmployee(@RequestBody EmployeeRequest request) {
        int i = orgEmployeeService.delOrgEmployee(getContext(), request.getEmployeeId());
        return Result.success(i);
    }


}

